/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package JFreeChartExtensions.chartextensions.fitter;


import JFreeChartExtensions.ExtendableChartPanel;
import JFreeChartExtensions.JChartMenu.ChartMenuListeners.RemoveAllFittersListener;
import JFreeChartExtensions.JChartMenu.JChartMenu;
import JFreeChartExtensions.chartextensions.AbstractChartPanelExtension;
import org.jfree.chart.ChartPanel;

/**
 *
 * @author Nobody
 */
public class FittingExtension extends AbstractChartPanelExtension {

    protected JChartMenu removeFittersMenuItem;
  
    public FittingExtension(ExtendableChartPanel panel) {
        super(panel);
        name = "FittingExtension";
    }

    @Override
    public void applyExtension(ChartPanel chartPanel) {
        this.chartPanel = (ExtendableChartPanel) chartPanel;
        removeFittersMenuItem = new JChartMenu("Remove all Fitters series");
        removeFittersMenuItem.addListener(new RemoveAllFittersListener((ExtendableChartPanel) chartPanel));
        chartPanel.getPopupMenu().add(removeFittersMenuItem);

        chartExtensionManager = new ReggresionFittingManager((ExtendableChartPanel) chartPanel);
        chartExtensionManager.register(chartPanel);

    }

    @Override
    public void removeExtension() {
         chartPanel.getPopupMenu().remove(removeFittersMenuItem);
         chartExtensionManager.unregister();

    }
}
